package com.voice.call.common;

import java.util.Map;

public class Result {
	private int code;
	private String msg;
	private Object data;
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Object getData() {
		return data==null?"":this.data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	public Result() {
		super();
		this.code = ResultEnum.SUCCESS.getCode();
		this.msg = ResultEnum.SUCCESS.getMsg();
	}
	public Result(int code, String msg) {
		super();
		this.code = code;
		this.msg = msg;
	}
	public Result(Object data) {
		this.code = ResultEnum.SUCCESS.getCode();
		this.msg = ResultEnum.SUCCESS.getMsg();
		this.data = data;
	}
	public Result(Object data,String lang) {
		
		this.code = ResultEnum.SUCCESS.getCode();
		this.msg = new ConstLang(ResultEnum.SUCCESS.toString(), lang).getMsg();
		this.data = data;
	}
	public Result(ResultEnum rsEnum) {
		super();
		this.code = rsEnum.getCode();
		this.msg = rsEnum.getMsg();
	}
	public Result(ResultEnum rsEnum,String lang) {
		super();
		this.code = rsEnum.getCode();
		this.msg = new ConstLang(rsEnum.toString(), lang).getMsg();
	}
	public Result(int code, String msg, Object data) {
		super();
		this.code = code;
		this.msg = msg;
		this.data = data;
	}
	
	public  void changeLange(String lang) {
		ResultEnum rs = ResultEnum.getEnumByCode(this.code);
		if (rs!=null) {
			this.msg = new ConstLang(rs.toString(), lang).getMsg();
		}
	}
	public void changeMessage(Map<String, Object> params) {
		String lang = ConstLang.getLang(params);
		ResultEnum rs = ResultEnum.getEnumByCode(this.code);
		if (rs!=null) {
			this.msg = new ConstLang(rs.toString(), lang).getMsg();
		}
	}
	
}
